#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10;

int n, K, a[N];
ll suf[N], pre[N], s[N], mx;

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in, K = in; rep(i, 1, n) a[i] = in, s[i] = s[i - 1] + a[i], pre[i] = pre[i - 1] + (a[i] >= 0 ? a[i] : 0);
	per(i, n, 1) suf[i] = suf[i + 1] + (a[i] >= 0 ? a[i] : 0);
	rep(i, 1, n - K + 1) {
		mx = max(mx, max(s[i + K - 1] - s[i - 1], 0ll) + pre[i - 1] + suf[i + K]);
	} cout << mx << endl;
}
